<!-- start header -->
<div class="MainHeaderFix">
    <div class="MainHeader">
        <div class="MainHeaderCon">
            <a target="_self" href="/" class="logo"></a>
            <ul class="NavMenulist">
                <li class="active" data-state="0">
                    <a href="/">首页</a>
                </li>
                <li>
                    <a href="/rank">排行榜</a>
                </li>
                <li>
                    <a href="/mall">商城</a>
                </li>
                <li>
                    <a href="/pay">充值</a>
                </li>
                <!--<li>-->
                    <!--<a href="/zt/zhengjing">正经男女</a>-->
                <!--</li>-->
                <li>
                    <a href="/entry">申请入驻</a>
                </li>
                <li>
                    <a href="/app/download/pc/">下载</a>
                </li>

            </ul>
            <div class="UserZone">
                <ul class="user-fn">
                    <li class="fn-login" name="GroupMainUserLogin" UserSign="In">
                        <a href="javascript:;" onclick="_czc.push(['_trackEvent', '头部登录', '登录', '首页头部登录']);"
                           class="fn-alink">登录</a></li>
                    <li class="fn-sline" name="GroupMainUserLogin">|</li>
                    <li class="fn-reg" name="GroupMainUserLogin" UserSign="Up">
                        <a href="javascript:;" onclick="_czc.push(['_trackEvent', '头部注册', '注册', '首页头部注册']);"
                           class="fn-alink">注册</a>
                    </li>
                    <li class="fn-avatar" id="MainHeader_MiniInfo" name="GroupMainUserInfo">
                        <a href="/member/user/" class="fn-alink">
                            <img id="MainHeader_UserPhoto" class="avatar">
                            <span class="avatar-mask"></span>
                        </a>
                        <div class="fn-mini-info">
                            <div class="fn-mini-arrow"></div>
                            <div class="top-mini-info clearfix">
                                <div class="usr-ava">
                                    <a href="/member/user/">
                                        <img id="MainHeader_MiniInfo_UserPhoto" class="photo"/>
                                    </a>
                                </div>
                                <dl class="usr-info" id="ajs-usr-info">
                                    <dd>
                                        <i class="ico-level"></i>
                                        <span id="MainHeader_MiniInfo_UserNickName" class="username"></span>
                                        <i class="icon-edit"></i>
                                        <p class="ajax-edit">
                                            <input type="text" value="" maxlength="8" class="ajax-username"
                                                   name="nicknames">
                                            <input type="button" value="保存" class="ajax-save" name="save"
                                                   id="J_Header_NickName_Edit">
                                        </p>

                                    </dd>
                                    <dd>
                                        <i class="icon-ucoin"></i>
                                        金币：<em class="color-orage" id="J_MainUser_Coin">-</em>
                                    </dd>
                                    <dd>
                                        <i class="icon-ubean"></i>
                                        金豆：<em class="color-orage" id="J_MainUser_Beans">-</em>
                                        <a href="/pay" class="gopay">充值</a>
                                    </dd>
                                </dl>
                            </div>
                            <div class="bottom-mini-info clearfix">
                                <p class="bott-out" UserSign="Out"><a href="javascript:;">退出</a></p>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="NavSearch">
                <input value="" autocomplete="off" class="search-input" id="searchinput" type="text"
                       placeholder="输入昵称或房间号">
                <a href="javascript:;" class="btn-search" onclick="_czc.push(['_trackEvent', '头部搜索', '搜索', '首页头部搜索']);"
                   id="J_Global_Search"></a>
            </div>
        </div>
    </div>
</div>
<!-- end header -->
<script>
    var _czc = _czc || [];
    $(function () {
        //导航菜单
        var host = window.location.host;
        var href = window.location.href;
        href = href.replace("http://" + host, "");
        $(".NavMenulist a[href='" + href + "']").parent("li").addClass("active").attr("data-state", "0").siblings("li").removeClass("active").removeAttr("data-state");
        $(".NavMenulist li").hover(function () {
            $(this).addClass("active");
        }, function () {
            if ($(this).attr("data-state") == 0) {
                return;
            }
            $(this).removeClass("active");
        });
        //////////////////////////////////////////////////////////
        //THISMASTER
        //////////////////////////////////////////////////////////
        var _ThisMaster = {
            MiniInfo: $('#MainHeader_MiniInfo'),
            MiniInfo_Content: $('#MainHeader_MiniInfo > .fn-mini-info'),
            MiniInfo_Timeout: null
        }
        $('#searchinput').keyup(function () {
            var event = window.event || arguments.callee.caller.arguments[0];
            if (event.keyCode == 13) {
                var keyword = $.trim($("#searchinput").val());
                if (!keyword) {
                    $.CommonMain.Modal_Tip("请输入搜索条件", {Timeout: 2000});
                    return;
                }
                window.location.href = '/search?key=' + keyword;
            }
        })

        $('#J_Global_Search').on('click', function () {
            //////////////////////////////////////////////
            //搜索查询
            ////////////////////////////////////////////
            var keys = $.trim($('#searchinput').val());
            if (!keys) {
                $.CommonMain.Modal_Tip("请输入搜索条件", {Timeout: 2000});
                return;
            }
            $(this).attr('href', '/search?key=' + keys);

        });
        /////////////////////////////////////////////////////
        //PageInit
        /////////////////////////////////////////////////////
        $.CommonMain.PageInit();
        /////////////////////////////////////////////////////
        //绑定用户信息(已登陆)
        /////////////////////////////////////////////////////
        if (!_StateData.IsLogin) {
            return;
        }
        $('#MainHeader_UserPhoto').attr('src', $.Common.ImageBind.UserAvatar.fnURL(_StateData.User_ID, "54.54"));
        $('#MainHeader_MiniInfo_UserPhoto').attr('src', $.Common.ImageBind.UserAvatar.fnURL(_StateData.User_ID, "54.54"));
        $('#MainHeader_MiniInfo_UserNickName').text(_StateData.NickName);
        $.CommonMain.User_UserInfo(function (json) {
            $('#J_MUser_Cion').text(json.data.Coin);
            $('#J_MUser_Beans').text(json.data.Beans);
            $('#J_MainUser_Coin').text(json.data.Coin);
            $('#J_MainUser_Beans').text(json.data.Beans);
        });
        /////////////////////////////////////////////////////
        //修改用户昵称
        /////////////////////////////////////////////////////
        $("#ajs-usr-info .icon-edit").on("click", function () {
            $(this).prev(".username").hide();
            $(this).hide();
            $("#ajs-usr-info .ajax-edit").show();
        });
        $('input[name="nicknames"]').val(_StateData.NickName);
        $('#J_Header_NickName_Edit').on('click', function () {
            var parames = {};
            parames.NickName = $.trim($('input[name="nicknames"]').val()).replace(/[ ]/g, "");
            if (parames.NickName.length > 8) {
                $.CommonMain.Modal_Tip('昵称不能超过8个字符', {Timeout: 1000});
                $('input[name="NickNames"]').focus();
                return false;
            }
            if (!parames.NickName) {
                $.CommonMain.Modal_Tip('昵称不能为空', {Timeout: 1000});
                $('input[name="NickNames"]').focus();
                return false;
            }
            $.KOC.Loading.Open();
            $.ajax({
                url: '/ajax/user.user-info.update',
                type: 'post',
                dataType: 'json',
                data: {
                    NickName: parames.NickName
                },
                success: function (data) {
                    $.KOC.Loading.Close();
                    if (data.flag !== 0) {
                        $.CommonMain.Modal_Tip(data.msg + "(" + data.flag + ")", {Timeout: 2000});
                        return;
                    }
                    $.CommonMain.Modal_Tip('昵称修改成功', {Timeout: 4000});
                    var host = window.location.host;
                    var href = window.location.href;
                    href = href.replace("http://" + host, "");
                    location.href = href;
                }
            });


        });
        /////////////////////////////////////////////////////
        //用户信息(Mini)窗口事件
        /////////////////////////////////////////////////////
        _ThisMaster.MiniInfo.hover(function () {
            if (_ThisMaster.MiniInfo_Timeout) {
                clearTimeout(_ThisMaster.MiniInfo_Timeout);
                _ThisMaster.MiniInfo_Timeout = null;
            }
            $(_ThisMaster.MiniInfo_Content).show();
        }, function () {
            clearTimeout(_ThisMaster.MiniInfo_Timeout);
            _ThisMaster.MiniInfo_Timeout = setTimeout(function () {
                $(_ThisMaster.MiniInfo_Content).fadeOut();
            }, 200);
        });
    });
</script>
<script>
    //测试
    $(function () {
        $(document).ready(function () {
            CNZZ();
        });
        function CNZZ() {
            var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");
            var html = unescape("%3Cspan id='cnzz_stat_icon_1259726799'%3E%3C/span%3E%3Cscript  src='" + cnzz_protocol + "s11.cnzz.com/z_stat.php%3Fid%3D1259726799' type='text/javascript'%3E%3C/script%3E");
            $("body").append(html);
        }
    })
</script>
